#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    bool validPalindrome(string s)
    {
        int left = 0;
        int right = s.size() - 1;
        int del = 0;

        while (left < right)
        {
            if (s[left] == s[right])
            {
                ++left;
                --right;
            }
            else
            {
                return checkPalindrome(s, left + 1, right) ||
                    checkPalindrome(s, left, right - 1);
            }
        }

        return true;
    }

    bool checkPalindrome(const string& s, int left, int right)
    {
        while (left < right)
        {
            if (s[left] == s[right])
            {
                ++left;
                --right;
            }
            else
            {
                return false;
            }
        }

        return true;
    }
};